package com.wht.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wht.domain.Music;
import com.wht.mapper.MusicMapper;
import com.wht.utils.MyBatisUtils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @author wanghaotian
 * time:2022/11/24,0024 21:29
 * description:
 */

public class FindMusicServiceImpl implements FindMusicService {
    @Override
    public List<Music> selectAllMusic() {
        MusicMapper mapper = MyBatisUtils.getMapper(MusicMapper.class);
        List<Music> music = mapper.selectAllMusic();
        return music;
    }

    @Override
    public Music selectOneMusic(Integer mid) {
        MusicMapper mapper = MyBatisUtils.getMapper(MusicMapper.class);
        Music music = mapper.selectOneMusic(mid);
        return music;
    }

    @Override
    public PageInfo<Music> selectMusicPage(int parseInt, int i) {
        MusicMapper mapper = MyBatisUtils.getMapper(MusicMapper.class);
        PageHelper.startPage(parseInt, i);
        List<Music> music = mapper.selectAllMusic();
        PageInfo<Music> pageInfo = new PageInfo<>(music);
        return pageInfo;
    }
}
